package za.um.td.prototyping;

import com.jme.bounding.BoundingBox;
import com.jme.entity.Entity;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.shape.Quad;

public class BoardBlock extends Entity {

	private Quad blockQuad = null;
	private Vector3f pos = null;
	private float width, height;

	public BoardBlock(String id, Vector3f pos, float blockWidth,
			float blockHeight) {
		super(id);
		this.pos = pos;
		width = blockWidth;
		height = blockHeight;
		initSpatial();
	}

	private void initSpatial() {
		blockQuad = new Quad("BoardQuad", width, height);

		// This block will always be horizontal, so rotate it 90 degrees
		float[] angles = { -1.5808f, 0.0f, 0.0f };
		blockQuad.rotatePoints(new Quaternion(angles));
		blockQuad.updateGeometricState(0.0f, true);

		blockQuad.setLocalTranslation(pos);

		blockQuad.setModelBound(new BoundingBox());
		blockQuad.updateModelBound();
		setSpatial(blockQuad);
	}
	
	public void updateRenderState() {
		getSpatial().updateRenderState();
	}

	public float getWidth() {
		return width;
	}

	public float getHeight() {
		return height;
	}
}
